-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ContentSwitcher): add icon-only ContentSwitcher #13378
feat(ContentSwitcher): add icon-only ContentSwitcher #13378
Conversation
✅ Deploy Preview for carbon-components-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
1a69cd7
to
2d326fe
Compare
packages/react/src/components/ContentSwitcher/ContentSwitcher.js
Outdated
Show resolved
Hide resolved
c458e3f
to
9ac8e18
Compare
aeca559
to
95a9c42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 🎉 🏆
@@ -141,9 +140,14 @@ export default class ContentSwitcher extends React.Component { | |||
...other | |||
} = this.props; | |||
|
|||
const isIconOnly = React.Children.map(children, (child) => { | |||
return child.type.displayName === 'IconSwitch'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make a note here that this locks the API so consumers can only use IconSwitch. It could prove problematic if someone were to to roll their own IconSwitch component and names it something different. Let's cross that bridge if we come to it though - no need to over optimize for it right now imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good!! Just a couple of comments.
- I noticed there is a slight shadow or gray color bug on the left side of the first section when its selected
- When the last section is selected and has focus, the focus border does not completely overlap the selected color layer on the right side.
-
The icon color in the sections that are unselected should be
$icon-primary
. -
The Large size content switcher should have 20px icons instead of 16px.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending lauren's style issue
d57b8b9
to
8cd5b3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2df73f3
to
dbf5359
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Thanks TJ! ✅
Closes #12811
Adds in a new icon-only
ContentSwitcher
Changelog
New
IconSwitch
component was created, and rendered as a child ofContentSwitcher
. When this is used instead ofSwitch
, it will render anIconButton
.name
passed intoIconSwitch
will render theTooltip
text. This will also set thearia-label
on theIconButton
IconSwitch
ContentSwitcher
Changed
ContentSwitcher
now passes alongsize
to its children.size
prop types to valid v11 sizes.ContentSwitcher
wrapperClasses
prop toIconButton
. I needed a way to surface selected + disabled states to the outermost wrapper, and adding one inIconSwitch
was causing therole="tab"
be too far removed from its parent, and causing screenreader issues (Each button readTab 1 of 1
). Since it is now just 1 level removed, the screen reader announces the number of tabs correctly.Removed
with layer
snapshot and replaced it with the new icon-only story. Thewith layer
story has no visual differences from the default story.Testing / Reviewing
Go to
ContentSwitcher
and check out the icon-only story.Make sure there are no regressions to the standard
ContentSwitcher